<?php

declare(strict_types=1);

namespace App\Orchid;

use Orchid\Platform\Dashboard;
use Orchid\Platform\ItemPermission;
use Orchid\Platform\OrchidServiceProvider;
use Orchid\Screen\Actions\Menu;
use Orchid\Support\Color;

class PlatformProvider extends OrchidServiceProvider
{
    /**
     * Bootstrap the application services.
     *
     * @param Dashboard $dashboard
     *
     * @return void
     */
    public function boot(Dashboard $dashboard): void
    {
        parent::boot($dashboard);

        // ...
    }

    /**
     * Register the application menu.
     *
     * @return Menu[]
     */
    public function menu(): array
    {
        return [
            Menu::make('仪表盘')
                ->icon('bs.speedometer2')
                ->title('内容管理')
                ->route('platform.main'),

            Menu::make('文章管理')
                ->icon('bs.file-text')
                ->route('platform.posts')
                ->permission('platform.posts.list'),

            Menu::make('分类管理')
                ->icon('bs.folder')
                ->route('platform.categories')
                ->permission('platform.categories'),

            Menu::make('标签管理')
                ->icon('bs.tag')
                ->route('platform.tags')
                ->permission('platform.tags'),

            Menu::make('页面管理')
                ->icon('bs.file')
                ->route('platform.pages')
                ->permission('platform.pages.list'),

            Menu::make('媒体库')
                ->icon('bs.image')
                ->route('platform.media')
                ->permission('platform.media')
                ->divider(),

            Menu::make('用户管理')
                ->icon('bs.people')
                ->route('platform.systems.users')
                ->permission('platform.systems.users')
                ->title('系统管理'),

            Menu::make('角色管理')
                ->icon('bs.shield')
                ->route('platform.systems.roles')
                ->permission('platform.systems.roles'),

            Menu::make('系统设置')
                ->icon('bs.gear')
                ->route('platform.settings')
                ->permission('platform.settings')
                ->divider(),

            Menu::make('开发文档')
                ->title('帮助')
                ->icon('bs.box-arrow-up-right')
                ->url('https://orchid.software/en/docs')
                ->target('_blank'),

            Menu::make('更新日志')
                ->icon('bs.box-arrow-up-right')
                ->url('https://github.com/orchidsoftware/platform/blob/master/CHANGELOG.md')
                ->target('_blank')
                ->badge(fn () => Dashboard::version(), Color::DARK),
        ];
    }

    /**
     * Register permissions for the application.
     * 
     * 权限现在由PermissionServiceProvider管理
     *
     * @return ItemPermission[]
     */
    public function permissions(): array
    {
        return [];
    }
}
